package com.smart.mapper;

import com.smart.pojo.Department;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lyj
 * @since 2023-04-19
 */
public interface DepartmentMapper extends BaseMapper<Department> {

    @Select("select d.*\n" +
            "from user u,\n" +
            "role r,\n" +
            "department d\n" +
            "where u.del_flag=0\n" +
            "and r.del_flag=0\n" +
            "and d.del_flag=0\n" +
            "and u.role_id=r.id\n" +
            "and r.department_id=d.id\n" +
            "and u.id=#{userId}")
    Department queryByUserId(Long userId);
}
